import org.slf4j.LoggerFactory
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger
import cats.effect.*
import cats.implicits.*
import cats.effect.unsafe.implicits.global
import com.rock.securityresearch.util.DateUtil

import java.time.LocalDate

object TestLog extends App{
    private val LOG = LoggerFactory.getLogger(classOf[TestLog.type])
    println(DateUtil.getWeekOfDate(LocalDate.of(2000, 1, 17)))
//    LOG.info("hello world")
//    MyThing.doSomething[IO].unsafeRunSync()
}
//def testLog(): Unit = {
//    import org.typelevel.log4cats.Logger
//    import org.typelevel.log4cats.slf4j.Slf4jLogger
//    import cats.effect._
//    import cats.implicits._
//    implicit def logger[F[_] : Sync]: Logger[F] = Slf4jLogger.getLogger[F]
//
//    Logger[IO].info("Logging Start Something")
//    println("...log....")
//    MyThing.doSomething[IO].unsafeRunSync()
//}



object MyThing {
    // Impure But What 90% of Folks I know do with log4s
    implicit def logger[F[_]: Sync]: Logger[F] = Slf4jLogger.getLogger[F]

    // Arbitrary Local Function Declaration
    def doSomething[F[_]: Sync]: F[Unit] =
        Logger[F].info("Logging Start Something") *>
            Sync[F].delay(println("I could be doing anything"))
                .attempt.flatMap{
                case Left(e) => Logger[F].error(e)("Something Went Wrong")
                case Right(_) => Sync[F].pure(())
            }
}